package com.rodagroup.study.modules.svc.consumer;

import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.demo.HelloReply;
import org.apache.dubbo.demo.HelloRequest;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

public class SvcConsumerApplication {

  public static void main(String[] args) {
    try {
      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
      context.start();
      System.out.println("dubbo svc consumer endpoint started");

      DemoService demoService = context.getBean("demoService", DemoService.class);
      HelloRequest request = HelloRequest.newBuilder().setName("Jake").build();
      HelloReply reply = demoService.sayHello(request);
      System.out.println("result: " + reply.getMessage());

      System.in.read();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

}
